var express = require('express');
var path = require('path');

var cookieParser = require('cookie-parser');
var logger = require('morgan');
var fs =require("fs");
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();
app.listen(8055);

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);

app.get("/getkcbdata",function (req,res) {


    fs.readFile("./public/data/kcb1.json",function (err,data) {

        if(!err){

            let da=JSON.parse(data.toString());
            res.json(da);
        }
    });

});

module.exports = app;
